package com.demo.control;

import com.demo.pojo.Account;
import com.demo.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import java.util.List;

@Controller
public class AccountController {
    @Autowired
    private AccountService accountService;

    /**
     * 查询所有用户
     * @return
     */
    public List<Account> selectAll() {
        return accountService.selectAll();
    }

    /**
     * 根据ID查询用户
     * @param id
     * @return
     */
    public Account getById(int id) {
        return accountService.getById(id);
    }

    /**
     * 删除单个用户
     * @param id
     * @return
     */
    public String delete(int id) {
        return accountService.delete(id)?"删除成功":"删除失败";
    }

    /**
     * 修改用户数据
     * @param id
     * @return
     */
    public String update(int id) {
        return accountService.update(id)?"修改成功":"修改失败";
    }

    /**
     * 新增用户
     * @param account
     * @return
     */
    public String insert(Account account) {
        return accountService.insert(account)?"新增成功":"新增失败";
    }
}
